package com.ticket.sass.admin.dto.input.printer;

import com.baomidou.mybatisplus.annotation.TableField;
import com.ticket.sass.admin.validator.InEnum;
import com.ticket.sass.common.entity.tenant.enums.CommodityCloudPrinterType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.AssertTrue;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author ywb
 * @date 2024-04-08 11:25
 */
@Data
@ApiModel
public class CommodityCloudPrinterUpdInput {
    @NotNull(message = "ID 不能为空")
    @ApiModelProperty(value = "ID")
    private Long id;
    
    @NotBlank(message = "名称不能为空")
    @ApiModelProperty(value = "名称")
    @Size(max = 255, message = "名称长度不能超过255个字符")
    private String name;
    
    @NotNull(message = "类型不能为空")
    @InEnum(intValues = {1})
    @ApiModelProperty(value = "类型")
    private Short type;
    
    @ApiModelProperty(value = "数据")
    private Map<String, String> data;
    
    @ApiModelProperty(value = "影厅")
    private List<Long> hallIds = new ArrayList<>();
    
    @NotNull(message = "是否默认不能为空")
    @TableField(value = "is_default")
    private Boolean isDefault;
    
    @AssertTrue(message = "配置必须符合规范")
    public boolean isJumpConfig() {
        return CommodityCloudPrinterType.Companion.valueOf(type).isConfigValid(data);
    }
}
